# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=kernelpop
pkgver=238.b3467d3
pkgrel=5
pkgdesc='Kernel privilege escalation enumeration and exploitation framework.'
groups=('blackarch' 'blackarch-exploitation' 'blackarch-automation')
arch=('x86_64' 'aarch64')
url='https://github.com/spencerdodd/kernelpop'
license=('custom:unknown')
depends=('python')
makedepends=('git' 'pyinstaller')
source=("git+https://github.com/spencerdodd/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  pyinstaller "$pkgname.py" --onefile

  cp "dist/$pkgname" .
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec /usr/share/$pkgname/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

